<?php
// +----------------------------------------------------------------------
// | 中联致远服务端框架
// +----------------------------------------------------------------------
// | Copyright (c) 2018 http://www.zhongliansoft.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: tony <tanyu@zhongliansoft.com>
// +----------------------------------------------------------------------

namespace app\Manage\controller;

use app\common\controller\Manage;
use app\common\model\Common;
use app\common\model\BookAccount as BookAccountModel;
use app\common\model\ViewGetDepts as ViewGetDeptsModel;
use app\common\model\ViewGetYears as ViewGetYearsModel;
use app\common\model\ViewGetSeasons as ViewGetSeasonsModel;
use app\common\model\ViewGetDirs as ViewGetDirsModel;
use app\common\model\Config as ConfigsModel;
use think\facade\Request;

class BookAccount extends Manage
{ 
    // 账单
    public function index()
    {   
        if(Request::isAjax())
        {
            $bookAccountModel = new BookAccountModel();
            return $bookAccountModel->tableData(input('param.'));
        }

        //获取部门列表
        $viewGetDeptsModel = new ViewGetDeptsModel();
        $dep_nameList = $viewGetDeptsModel->select();
        $this->assign('depList', $dep_nameList);

        //获取年度列表
        $viewGetYearsModel = new ViewGetYearsModel();
        $year_List = $viewGetYearsModel->select();
        $this->assign('yearList', $year_List);

        //获取季度列表
        $viewGetSeasonsModel = new ViewGetSeasonsModel();
        $season_List = $viewGetSeasonsModel->select();
        $this->assign('seasonList', $season_List);
        
        //获取方向列表
        $ViewGetDirsModel = new ViewGetDirsModel();
        $dir_List = $ViewGetDirsModel->select();
        $this->assign('dirList', $dir_List);

        //获取当前年度季度
        $ConfigsModel = new ConfigsModel();
        $year = $ConfigsModel->getYear();
        $season = $ConfigsModel->getSeason();
        $this->assign('curr_year', $year);
        $this->assign('curr_season', $season);
        $this->assign('userId', session('manage.id'));
 
        return $this->fetch("/book_account/index");
    }

    /**
     *  汇总账单
     * @return array|mixed
     */
    public function bookAccount()
    {
        $bookAccountModel = new BookAccountModel();
        return $bookAccountModel->bookAccount(input('param.'));
    }
}